export const dealRouterData = arr => {
	let res = []
	arr.forEach(i => {
		let cur = { meta: {} }
		cur.meta.title = i.menuName
		cur.meta.id = i.id
		cur.meta.icon = i.menuIcon
		cur.meta.type = i.menuType
		cur.meta.hide = i.hideFlag
		cur.meta.whetherEnable = i.whetherEnable
		cur.meta.parentUuid = i.parentUuid
		cur.meta.parentUuids = i.parentUuids
		cur.path = i.menuHref
		if (i.menuAssemblyHref.includes('http')) {
			cur.component = () => import('@/view/' + 'httpView' + '/index.vue')
		} else {
			cur.component = () =>
				import('@/view/' + i.menuAssemblyHref + '/index.vue')
		}
		cur.meta.menuAssemblyHref = i.menuAssemblyHref
		let nameList = cur.path.startsWith('/')
			? cur.path.split('').slice(1)
			: cur.path.split('')
		nameList[0] = nameList[0].toUpperCase()
		cur.name = nameList.join('')
		if (i.children && i.children.length > 0) {
			if (i.menuType == 1) {
				cur.buttonList = i.children
			} else {
				cur.children = dealRouterData(i.children)
			}
		}
		res.push(cur)
	})
	return res
}
export const getRoute = (path, list) => {
	if (!path) {
		return null
	} else {
		if (path.includes('/')) {
			const arr = path.split('/')
			path = arr[arr.length - 1]
		}
	}
	let res
	for (let i = 0; i < list.length; i++) {
		if (res) break
		if (list[i].path == path) {
			res = list[i]
		} else {
			if (list[i].children && list[i].children.length > 0) {
				res = getRoute(path, list[i].children)
			}
		}
	}
	return res
}
